// sgu350
// ml:run = $bin < input
#include <iostream>
#include <vector>
#include <unordered_set>

std::vector<int> ans;
std::unordered_set<int> all;
std::unordered_set<int> vis;
int const maxn = 200;
int a[maxn];
int m;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin >> m;
    for (int i = 0; i < m; i++) {
        std::cin >> a[i];
        all.insert(a[i]);
    }

    ans.push_back(0);
    vis.insert(0);
    for (int i = 0; i < m; i++) {
        if (vis.count(a[i])) continue;
        bool ok = true;
        for (size_t j = 0; j < ans.size(); j++)
            if (!all.count(ans[j] ^ a[i])) { ok = false; break; }
        if (ok) {
            ans.push_back(a[i]);
            for (size_t j = 0; j < ans.size() - 1; j++)
                vis.insert(ans[j] ^ a[i]);
        }
    }
    for (auto i : ans) std::cout << i << " ";
    std::cout << "\n";
}

